package com.hrzyit.whistle.cases.ui.fragment

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.hrzyit.base.ui.fragment.BaseMvpFragment
import com.hrzyit.whistle.cases.R
import com.hrzyit.whistle.cases.data.bean.CategoryDetailsEntity
import com.hrzyit.whistle.cases.data.bean.CategoryEntity
import com.hrzyit.whistle.cases.data.bean.SysDictEntity
import com.hrzyit.whistle.cases.injection.component.DaggerCaseTypeComponent
import com.hrzyit.whistle.cases.injection.module.CaseTypeModule
import com.hrzyit.whistle.cases.presenter.CaseTypePresenter
import com.hrzyit.whistle.cases.presenter.view.CaseTypeView

/**
 *
 * @author YangWei
 * @date 2019/4/1
 */
class CaseTypeFragment:BaseMvpFragment<CaseTypePresenter>(),CaseTypeView {


    /**
     * 在创建 View 时
     */
    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        super.onCreateView(inflater, container, savedInstanceState)
        // 加载 Fragment
        return inflater.inflate(R.layout.fragment_case_type, container, false)
    }

    /**
     * 在 View 被创建完成
     */
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        Log.e("-------------->","进入到 Fragment")
        initView()
        loadData()
    }

    /**
     * 初始化视图
     */
    private fun  initView(){

        // 1. 类型、大类、小类全没有选
        // 2. 类型已选；大类、小类没选
        // 3. 类型、大类已选；小类没选

    }

    /**
     * 加载数据
     */
    private fun loadData(){
        mPresenter.getCaseQuestionType()

    }

    override fun injectComponent() {

        DaggerCaseTypeComponent.builder()
            .activityComponent(mActivityComponent)
            .caseTypeModule(CaseTypeModule())
            .build()
            .inject(this)

        mPresenter.mView = this
    }

    /**
     * 获取案件类型：小类回调
     */
    override fun onGetSecondCategoryResult(t: MutableList<CategoryEntity>) {
        Log.d("小类",t.get(0).sortName)
    }

    /**
     * 获取案件类型：大类回调
     */
    override fun onGetOneCategoryResult(t: MutableList<CategoryEntity>) {

        Log.d("大类",t.get(0).sortName)
    }

    /**
     * 获取案件类型：问题类型回调
     */
    override fun onGetCaseQuestionTypeResult(t: MutableList<SysDictEntity>) {

        Log.e("问题类型--------","${t.size}")

    }

    /**
     * 获取案件立案条件，回调
     */
    override fun onGetCaseConditionListResult(t: MutableList<CategoryDetailsEntity>) {
        // TODO 2019/4/9 - 待完成内容：获取案件立案条件，回调
    }
}